gulp.task(ꞌphpspecꞌ)   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
var gulp = require('gulp'),
2
    phpspec = require('gulp-phpspec'),
3
    behat = require('gulp-behat'),
4
    notify = require('gulp-notify'),
5
    path = require('path'),
6
    _ = require('lodash');
7
8
gulp.task('phpspec', function() {
9
    var options = {
10
        clear: true,
11
        formatter: 'dot',
12
        verbose: 'v',
13
        notify: true,
14
        noInteraction: true
15
    };
16
    gulp.src('phpspec.yml')
17
        .pipe(phpspec('', options))
18
        .on('error', notify.onError(testNotification('fail', 'phpspec')))
19
        .pipe(notify(testNotification('pass', 'phpspec')));;
20
});
21
22
gulp.task('behat', function() {
23
    var options = {
24
        format: 'progress',
25
        notify: true
26
    };
27
    gulp.src('behat.yml')
28
        .pipe(behat('', options))
29
        .on('error', notify.onError(testNotification('fail', 'behat')))
30
        .pipe(notify(testNotification('pass', 'behat')));
31
});
32
33
gulp.task('watch', function() {
34
    gulp.watch(['src/**/*.php', 'spec/**/*.php', 'features/**/*.feature'], ['test']);
35
});
36
37
gulp.task('test', ['phpspec', 'behat']);
38
gulp.task('default', ['test', 'watch']);
39
40
function testNotification(status, pluginName, override) {
41
    return _.merge({
42
        title:   ( status == 'pass' ) ? 'Tests Passed' : 'Tests Failed',
43
        message: ( status == 'pass' ) ? '\n\nAll tests have passed!\n\n' : '\n\nOne or more tests failed...\n\n',
44
        icon:    path.join(__dirname, 'node_modules/gulp-' + pluginName, 'assets/test-' + status + '.png')
45
    }, override);;
46
}
47